#ifndef __PUBLIC_H__
#define __PUBLIC_H__
#include <map>
#include <unordered_map>

static const int SMALL_BUF_LEN = 128;
static const int MEDIAN_BUF_LEN = 512;
static const int LARGE_BUF_LEN = 1024;

enum COLOR_NUMBER {
    DEFAULT_COLOR = 0,
    INFO_COLOR = 36,
    ERROR_COLOR = 35,
    DEBUG_COLOR = 32,
    FATAK_COLOR = 31,
    LINE_COLOR = 32,
    FUNCTION_COLOR = 34,
    FILE_COLOR = 35,

};

enum LOG_LEVEL {
    INFO = 0,
    ERROR,
    DEBUG,
    FATAL
};

enum LOG_FEILD
{
    LINE_NUMBER = 0,
    FUNCTION_NAME,
    FILE_NAME
};

//日志级别，到日志色号的映射
static std::unordered_map<LOG_LEVEL, COLOR_NUMBER> logLevelColor = {
    {INFO, INFO_COLOR},
    {ERROR, ERROR_COLOR},
    {DEBUG, DEBUG_COLOR},
    {FATAL, FATAK_COLOR}
};

//（文件函数行号）的字段，到色号的映射
static std::unordered_map<LOG_FEILD, COLOR_NUMBER> logFeildColor = {
    {LINE_NUMBER, LINE_COLOR},
    {FUNCTION_NAME, FUNCTION_COLOR},
    {FILE_NAME, FILE_COLOR}
};

//日志级别，到对应名称的映射
static std::unordered_map<LOG_LEVEL, std::string> logLevelTypeString = {
    {INFO, "[INFO]"},
    {ERROR, "[ERROR]"},
    {DEBUG, "[DEBUG]"},
    {FATAL, "[FATAL]"},
};

//字符串(从环境变量那里读的)，与对应的枚举值的映射
static std::unordered_map<std::string, LOG_LEVEL> logLevelType = {
    {"INFO" ,INFO},
    {"ERROR" ,ERROR},
    {"DEBUG" ,DEBUG},
    {"FATAL" ,FATAL},
};

//这个是业务类型的枚举，0对应登录，1对应注册
enum BIZTYPE {
    LOGIN = 0,
    REGISTER = 1,
};

//redis的相关常量
static const std::string REDIS_IP = "127.0.0.1";
static const unsigned short REDIS_PORT = 6379;

//Mysql
static const std::string MYSQL_IP = "127.0.0.1";
namespace lsc{
    static const unsigned short MYSQLDB_PORT = 3306;
};

//这三个用来连接数据库
static const std::string USER = "root";
static const std::string PASSWORD = "12345"; 
static const std::string DB = "dsf";

#endif
